package com.MSofLectures.Tool;

import java.util.Random;

public class RandomStringCreater {
	/*
	 * @author
	 * 生成指定长度的随机字符串，存在bug：偶尔字符串长度会少一个，不知道为啥
	 */
	public static String createWithLettersAndNumbers(int length) {
		Random target = new Random();
		char[] numbersAndLetters = ("0123456789abcdefghjkmnopqrstuvwxyz"
				+ "0123456789ABCDEFGHJKMNOPQRSTUVWXYZ").toCharArray();//去掉了L和i
		char[] randBuffer = new char[length];
		for (int i = 0; i < randBuffer.length; i++)
			randBuffer[i] = numbersAndLetters[target.nextInt(68)];
		return new String(randBuffer);
	}
}
